include(${CMAKE_CURRENT_LIST_DIR}/FindZig.cmake)
if(ZIG_FOUND)
  set(CMAKE_C_COMPILER ${ZIG_EXECUTABLE} cc)
  set(CMAKE_CXX_COMPILER ${ZIG_EXECUTABLE} c++)
  set(ZIG_RUNTIME_DIR ${CMAKE_CURRENT_BINARY_DIR})
  include(${CMAKE_CURRENT_LIST_DIR}/TargetSupportsSymbolicLink.cmake)
  if(NOT TARGET_SUPPORTS_SYMBOLIC_LINK)
    include(${CMAKE_CURRENT_LIST_DIR}/TemporaryDirectory.cmake)
    if(EXISTS "${TEMPORARY_DIRECTORY}")
      set(ZIG_RUNTIME_DIR ${TEMPORARY_DIRECTORY})
    endif()
  endif()
  if(WIN32)
    set(CMAKE_AR ${ZIG_RUNTIME_DIR}/zig-ar.bat)
    file(WRITE ${CMAKE_AR} "@echo off\n\"${ZIG_EXECUTABLE}\" ar %*")
    set(CMAKE_LIB ${ZIG_RUNTIME_DIR}/zig-lib.bat)
    file(WRITE ${CMAKE_LIB} "@echo off\n\"${ZIG_EXECUTABLE}\" lib %*")
    set(CMAKE_RANLIB ${ZIG_RUNTIME_DIR}/zig-ranlib.bat)
    file(WRITE ${CMAKE_RANLIB} "@echo off\n\"${ZIG_EXECUTABLE}\" ranlib %*")
    set(CMAKE_DLLTOOL ${ZIG_RUNTIME_DIR}/zig-dlltool.bat)
    file(WRITE ${CMAKE_DLLTOOL} "@echo off\n\"${ZIG_EXECUTABLE}\" dlltool %*")
    set(CMAKE_OBJCOPY ${ZIG_RUNTIME_DIR}/zig-objcopy.bat)
    file(WRITE ${CMAKE_OBJCOPY} "@echo off\n\"${ZIG_EXECUTABLE}\" objcopy %*")
    set(CMAKE_RC_COMPILER ${ZIG_RUNTIME_DIR}/zig-rc.bat)
    file(WRITE ${CMAKE_RC_COMPILER} "@echo off\n\"${ZIG_EXECUTABLE}\" rc %*")
  else()
    set(CMAKE_AR ${ZIG_RUNTIME_DIR}/zig-ar)
    file(WRITE ${CMAKE_AR} "exec \"${ZIG_EXECUTABLE}\" ar \"$@\"")
    execute_process(COMMAND chmod a+rx ${CMAKE_AR})
    set(CMAKE_RANLIB ${ZIG_RUNTIME_DIR}/zig-ranlib)
    file(WRITE ${CMAKE_RANLIB} "exec \"${ZIG_EXECUTABLE}\" ranlib \"$@\"")
    execute_process(COMMAND chmod a+rx ${CMAKE_RANLIB})
    set(CMAKE_DLLTOOL ${ZIG_RUNTIME_DIR}/zig-dlltool)
    file(WRITE ${CMAKE_DLLTOOL} "exec \"${ZIG_EXECUTABLE}\" dlltool \"$@\"")
    execute_process(COMMAND chmod a+rx ${CMAKE_DLLTOOL})
    set(CMAKE_OBJCOPY ${ZIG_RUNTIME_DIR}/zig-objcopy)
    file(WRITE ${CMAKE_OBJCOPY} "exec \"${ZIG_EXECUTABLE}\" objcopy \"$@\"")
    execute_process(COMMAND chmod a+rx ${CMAKE_OBJCOPY})
  endif()
endif()
if(CMAKE_TOOLCHAIN_FILE)
endif()
